package com.geektime.customer.service.impl;

import com.geektime.config.JDBCTemplateUtil;
import com.geektime.customer.repository.CustomerRepository;
import com.geektime.customer.service.DruidDemoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: liaojh
 * @Date: 2022/10/24
 * @Description:
 */
@Service
@RequiredArgsConstructor
public class DruidDemoServiceImpl implements DruidDemoService {

    private final CustomerRepository customerRepository;

    private final JDBCTemplateUtil jdbcTemplateUtil;

    @Override
    public List demo1() {
        Map<String, Object> params = new HashMap<>();
        String sql = " SELECT * from customer;SELECT * from customer_2; ";
        return jdbcTemplateUtil.queryForList(sql, params);
    }

    @Override
    public List demo2() {
        Map<String, Object> params = new HashMap<>();
        String sql = " SELECT * from customer; ";
        return jdbcTemplateUtil.queryForList(sql, params);
    }

    @Override
    public List demo3() {
        Map<String, Object> params = new HashMap<>();
        String sql = " SELECT * from customer where id in (1, 2, 3, 4, 5) ";
        return jdbcTemplateUtil.queryForList(sql, params);
    }

    @Override
    public List demo4() {
        Map<String, Object> params = new HashMap<>();
        String sql = " SELECT * from customer where id in (1, 2, 3, 4, 5, 6, 7, 8, 9) ";
        return jdbcTemplateUtil.queryForList(sql, params);
    }


}
